class_name UnitStats
extends Resource

enum Rarity {
	COMMON,
	UNCOMMON,
	RARE,
	LEGENDARY
}

const RARITY_COLORS := {
	Rarity.COMMON: 		Color("124a2e"),
	Rarity.UNCOMMON: 	Color("1c527c"),
	Rarity.RARE: 		Color("ab0979"),
	Rarity.LEGENDARY: 	Color("ea940b"),
}

## 名称
@export var name: String

@export_category("Data")
## 稀有度
@export var rarity: Rarity 

## 金币消耗
@export var gold_cost := 1

## 星级
@export_range(1, 3) var tier := 1 : set = _set_tier

## 单位池中的数量
@export var pool_count := 5

@export_category("Visuals")
## 皮肤坐标
@export var skin_coordinates: Vector2i


## 获取合并单位数量
func get_combined_unit_count() -> int:
	return 3 ** (tier-1)


## 获取单位总共金币数量
func get_gold_value() -> int:
	return gold_cost * get_combined_unit_count()


func _set_tier(value: int) -> void:
	tier = value
	emit_changed()


func _to_string() -> String:
	return name
